package com.yuqiao.read.lambda;

import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;

public class Compressor {
    private final CompressStrategy compressStrategy;

    public Compressor(CompressStrategy compressStrategy){
        this.compressStrategy = compressStrategy;
    }

    public void compress(Path inFile, File outFile) throws IOException {
        try {
            OutputStream outputStream = new FileOutputStream(outFile);
            Files.copy(inFile,compressStrategy.compress(outputStream));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}
